/**
 * 获得过滤后的数据
 * @param arr
 */
export const filterFlatlist = (arr: API.DeviceTreeVO[]): flatResult => {
  if (arr.length) {
    let deviceArr: string[] = [];
    let areaArr: string[] | number[] = [];
    let stationCode: string | number = '';
    let tempArray = _.uniq(_.cloneDeep(arr));
    tempArray.forEach((item: API.DeviceTreeVO) => {
      if (item.nodeType === 'ROOT') {
        stationCode = item.stationId as string;
      } else if (item.nodeType === 'AREA') {
        areaArr.push(item.areaId);
      } else {
        deviceArr.push(item.deviceCode);
      }
    });
    return {
      stationCode,
      deviceArr,
      areaArr,
    };
  } else {
    return {
      stationCode: '',
      deviceArr: [],
      areaArr: [],
    };
  }
};
